<?php
/*
 *   This file is part of poat.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 */

define('ROOT_PATH',dirname(__FILE__)."/");
require_once (ROOT_PATH."xajax_core/xajax.inc.php");

$xajax = new xajax();
//$xajax->setFlag("debug",true);
//$xajax->setFlag("statusMessages",true);
//$xajax->setLogFile("c:/temp/po/xajax.log");

$objResponse = new xajaxResponse();
$objResponse->assign("progressdiv","style.visibility","hidden");

function loadHistory($id) {
	global $objResponse;
	
	include(ROOT_PATH."includes/history.php");
	$objResponse->assign("history_div_content","innerHTML",$content);

	return $objResponse;
}

function sendMessage($data) {
	global $objResponse;
	
	include(ROOT_PATH."includes/mp.php");
	$objResponse->assign("message_div_content","innerHTML",$content);

	return $objResponse;
}

function getHelp($msgid,$langid) {
	global $objResponse;

	include_once(ROOT_PATH."lang/lang_".$langid.".inc");
	
	$objResponse->assign("help_div_content","innerHTML",$LANG[$msgid]."<br><br>");
	return $objResponse;
}

function updateFile($data) {
	global $objResponse;

	include(ROOT_PATH."includes/fileupdate.php");
	$objResponse->assign("filerow".$data['id'],"innerHTML",$content);
	if (isset($message)) {
		$objResponse->assign("messagenotice","innerHTML",'<p class="usermessage" name="messagenotice" id="messagenotice">'.$message.'</p>');	
	} else {
		$objResponse->assign("messagenotice","innerHTML","");
	}
	$objResponse->assign("editelement","style.display","none");
	$objResponse->assign("edit_status_progress","innerHTML","");
	
	return $objResponse;


}

function rejectFile($rowid,$fileid) {
	global $objResponse;

	include(ROOT_PATH."includes/filecheckaction.php");
	$objResponse->assign("filerow".$rowid."-".$fileid,"style.display","none");
	return $objResponse;

}

function rejectPackage($rowid) {
	global $objResponse;

	include(ROOT_PATH."includes/filecheckaction.php");
	$objResponse->assign("filetable".$rowid,"style.display","none");
	return $objResponse;

}

function workload($teamid) {
	global $objResponse;
	
	include(ROOT_PATH."includes/workload.php");
	$objResponse->assign("workload_div_content","innerHTML",$content);

	return $objResponse;
}

function updateUser($data,$response) {
	global $objResponse;
	
	include(ROOT_PATH."includes/userupdate.php");
	
	if ($response!="reset") $objResponse->assign($response."row".$data['id'],"innerHTML",$content);

	if (isset($message)) {
		$objResponse->assign("messagenotice","innerHTML",'<p class="usermessage">'.$message.'</p>');	
	} else {
		$objResponse->assign("messagenotice","innerHTML","");
	}
	if (isset($error)) {
		$objResponse->assign("errornotice","innerHTML",'<p class="error">'.$error.'</p>');	
	} else {
		$objResponse->assign("errornotice","innerHTML","");
	}
	return $objResponse;
}

function sendMeMyFiles() {
	global $objResponse;

	include(ROOT_PATH."includes/sendmemyfiles.php");
	$objResponse->assign("noticediv_element_content","innerHTML",$content);
	return $objResponse;
}

$xajax->registerFunction("workload");
$xajax->registerFunction("rejectFile");
$xajax->registerFunction("rejectPackage");
$xajax->registerFunction("loadHistory");
$xajax->registerFunction("sendMessage");
$xajax->registerFunction("getHelp");
$xajax->registerFunction("updateFile");
$xajax->registerFunction("updateUser");
$xajax->registerFunction("sendMeMyFiles");
$xajax->processRequest();

?>